package com.company.managesystem.common;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.company.managesystem.R;

/**
 * 错误页面
 * Created by lqy on 2017/6/26.
 */

public class ErrorLayout extends RelativeLayout implements View.OnClickListener {
    private static String TAG="ErrorLayout";
    private Context mContext;
    private OnClickListener listener;
    private ImageView imageView;
    private TextView textView;

    public ErrorLayout(Context context){
        super(context);
        this.mContext = context;
    }

    public ErrorLayout(Context context, AttributeSet attr){
        super(context,attr);
        this.mContext = context;
    }

    private void init(){
        View view = View.inflate(mContext, R.layout.rl_errorlayout,null);
        imageView = (ImageView) view.findViewById(R.id.iv_errorview);
        textView = (TextView) view.findViewById(R.id.tv_errormsg);
        setOnClickListener(this);
        imageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                if (listener != null) {
                    listener.onClick(view);
                }
            }
        });
        addView(view);
    }

    @Override
    public void onClick(View view) {
        if (listener != null){
            listener.onClick(view);
        }
    }

    public void setOnLayoutClickListener(View.OnClickListener listener) {
        this.listener = listener;
    }
}
